#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <semaphore.h>
int main (int argc ,char **argv)
{
  int shm_id;
  char *ptr;
  char buf[100];
  sem_t *sem;
  if (argc !=2)
  {
    printf("usage:shm_open <pathname> \n");
    exit(1);
  }
  shm_id = shm_open(argv[1],O_RDWR|O_CREAT,0777);
  printf("shm_id = %d \n ",shm_id);
  ftruncate(shm_id,100);
  ptr = mmap(NULL,100,PROT_READ|PROT_WRITE,MAP_SHARED,shm_id,0);
  fgets(ptr,99,stdin);
  munmap(ptr,100);
  return 0;
}

